Skip to content

fix: upsert peer address on connect#61

Open
ben-kaufman wants to merge 7 commits intomainfrom
fix/peer-address-upsert-main
Open

fix: upsert peer address on connect#61
ben-kaufman wants to merge 7 commits intomainfrom
fix/peer-address-upsert-main

Conversation

@ben-kaufman
Copy link

This PR:

  1. Fixes PeerStore::add_peer silently ignoring address updates for already-known peers, causing the reconnection loop to use stale IPs indefinitely after an LSP node migration
  2. Reorders Node::connect to persist the peer address before attempting the connection, so the updated address is saved even when the connection races with an in-flight reconnection attempt at the old address
  3. Bumps version to v0.7.0-rc.27 with regenerated bindings

When an LSP node's IP changes (e.g., LND4 moving from 34.65.186.40 to 34.65.153.174), nodes that previously connected would keep retrying the old cached address forever. The root cause was two-fold: add_peer returned early for known peers without checking the address, and connect only persisted after a successful connection — meaning a racing reconnection loop could prevent the new address from ever being saved.

This is the same fix as #53 (targeting base/v0.7.0-rc.18) but rebased onto main.

See upstream issue #700.

QA Notes

Testing

  • cargo test --lib peer_store — runs the 3 unit tests (existing + 2 new: peer_address_updated_on_readd, peer_same_address_skips_persist)
  • cargo test peer_address_persisted_on_connect_failure — integration test validating persist-before-connect and upsert across restart (requires BITCOIND_EXE)
  • cargo clippy clean
  • Bindings regenerated and included

Integration

Made with Cursor

ben-kaufman and others added 7 commits February 24, 2026 07:24
PeerStore::add_peer previously returned early if a peer already existed,
silently discarding address updates. When an LSP node's IP changed, the
reconnection loop would indefinitely retry the stale cached address.

This commit:
1. Changes add_peer to upsert: if the peer exists but the address
   differs, update and re-persist it.
2. Reorders Node::connect to persist the peer *before* attempting the
   connection, so the new address is saved even if the connection
   races with an in-flight reconnection attempt at the old address.
3. Adds unit tests for the upsert logic and an integration test for
   persist-on-failed-connect.

See upstream issue lightningdevkit#700.

Co-authored-by: Cursor <cursoragent@cursor.com>
Split wallet_sync_request into separate full_scan and incremental
methods so only the needed request type is built. Introduce
WalletSyncRequest enum to carry the chosen variant through the
sync pipeline.

Spawn primary and additional wallet syncs concurrently in a single
JoinSet instead of running primary first. Batch
update_payment_store_for_all_transactions and write_node_metrics
into a single call after all updates are applied, and only when at
least one update succeeded.

Fix a pre-existing bug where additional wallet sync timestamps
were set even when apply_update_for_address_type failed.

Co-authored-by: Cursor <cursoragent@cursor.com>
…tched-payment-store

refactor: lazy sync requests and batched payment store updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants